home *** CD-ROM | disk | FTP | other *** search
- /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Copyright (C) 1994, by WATCOM International Inc. All rights %
- % reserved. No part of this software may be reproduced or %
- % used in any form or by any means - graphic, electronic or %
- % mechanical, including photocopying, recording, taping or %
- % information storage and retrieval systems - except with the %
- % written permission of WATCOM International Inc. %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- */
-
- #ifndef _WWINMAIN_HPP_INCLUDED
- #define _WWINMAIN_HPP_INCLUDED
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma pack(push,8);
- #pragma enum int;
- #endif
-
- #include <stdlib.h>
-
- #ifndef _WDEF_HPP_INCLUDED
- # include "wdef.hpp"
- #endif
- #ifndef _WSTRING_HPP_INCLUDED
- # include "wstring.hpp"
- #endif
- #ifndef _WAPPLIC_HPP_INCLUDED
- # include "wapplic.hpp"
- #endif
- #ifndef _WMEMORY_HPP_INCLUDED
- # include "wmemory.hpp"
- #endif
-
- #define MAINOBJECT( __main_class ) \
- class MyApplicationClass : public WApplication { \
- public: \
- __main_class *_mainForm; \
- \
- MyApplicationClass() : _mainForm( NULL ) { \
- SetEventHandler( WStartEvent, this, \
- (WEventHandler)&MyApplicationClass::StartHandler );\
- SetEventHandler( WRunEvent, this, \
- (WEventHandler)&MyApplicationClass::RunHandler );\
- SetEventHandler( WEndEvent, this, \
- (WEventHandler)&MyApplicationClass::EndHandler );\
- } \
- \
- ~MyApplicationClass() {} \
- \
- WBool StartHandler( WObject *, WStartEventData *event ) { \
- _mainForm = new __main_class; \
- if( !_mainForm || !_mainForm->Initialize() ){ \
- event->abortRun = TRUE; \
- event->exitCode = -1; \
- } \
- return TRUE; \
- } \
- \
- WBool RunHandler( WObject *, WRunEventData * ) { \
- WCurrentThread::ProcessMessages(); \
- return TRUE; \
- } \
- WBool EndHandler( WObject *, WEndEventData * ) { \
- delete _mainForm; \
- _mainForm = NULL; \
- return TRUE; \
- } \
- }; MAINOBJECT_CUSTOM( MyApplicationClass, __main_class )
-
-
- #define MAINOBJECT_CUSTOM( __app_class, __main_class ) \
- \
- W_REDEFINENEW \
- W_REDEFINEDELETE \
- \
- static __app_class _WAppObject; \
- \
- int WINAPI WinMain( HINSTANCE inst, HINSTANCE prev, \
- WAnsiChar * cmd, int show ) \
- { \
- if( _WAppObject.Initialize( inst, prev, cmd, show ) ){ \
- _WAppObject.Run(); \
- } \
- \
- return _WAppObject.Uninitialize(); \
- }
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma enum pop;
- #pragma pack(pop);
- #endif
-
- #endif // _WWINMAIN_HPP_INCLUDED
-